<?php

// +----------------------------------------------------------------------
// | Copyright (c) 2020 All rights reserved.
// +----------------------------------------------------------------------
// | User: Simony <1362229026@qq.com>
// | wechat: Shen86579595
// +----------------------------------------------------------------------
namespace app\admin\controller;

use app\admin\controller\Common;
use think\Db;

class View extends Common
{
    /**
     * User:Simony
     * Function: 会员查看日志列表
     * @return mixed
     */
    public function logList()
    {
        //params
        $field = input('get.field', '');
        $value = input('get.value', '');
        $search_field = input('get.search_field', '');
        $search_value = input('get.search_value', '');

        //where
        $where = [];

        //judge
        if ($field) $where[$field] = $value;
        if ($search_field) $where[$search_field] = $search_value;

        //model
        $viewLogModel = model('common/view/ViewLog');

        //getData
        $where = [
            ['v_l.type', 'eq', 2],
            ['v_l.price', 'gt', 0],
        ];

        $field = 'v_l.id,m1.username as username,m2.username as been_username,v_l.view_time,v_l.price,v_l.expire_time';
        $list = $viewLogModel->getViewLogList($where, 10, $field);

        //assign
        $this->assign('list', $list);
        $this->assign('page', $viewLogModel->page_info->render());
        return $this->fetch();
    }


}